package com.sc.admin.utils;

import java.util.Random;

public class IDUtils {
	public static long createGoodsId() {
		//用当前的系统时间的毫秒数+4位随机数
		long time= System.currentTimeMillis();
		//四位随机数
		Random random = new Random();
		int num = random.nextInt(10000);
		StringBuilder sNum = new StringBuilder();
		sNum.append(time);
		if(num<10) {
			sNum.append("000").append(num);
		}else if(num<100){
			sNum.append("00").append(num);
		}else if(num<1000) {
			sNum.append("0").append(num);
		}else {
			sNum.append(num);
		}
		return Long.parseLong(sNum.toString());
	}
	
	public static void main(String[] args) {
		System.out.println(IDUtils.createGoodsId());
	}
}
